var utils = require('../../../utils/util.js');
var c = require('../../../utils/config.js');
Page({
    data: {
        lists: [
        ],
        total_money:0,
        ym:'',
        page:1,
    },
    onShow: function () {
        utils.checkLogin();
        this.getList();
    },
    // //下拉刷新
    //   onPullDownRefresh: function () {
    //     this.setData({
    //       lists: [],
    //       page:1,
    //     });
    //     this.getList();
    //   },
    //上拉加载
      // onReachBottom: function () {
      //   this.getList();
      // },

    getList:function(){
        var that = this;
        var token = wx.getStorageSync("userinfo").wap_token;
        var ym = this.data.ym;
        var page = this.data.page;
        var data = {
            url:"/wsgoods/ordergoods/sold",
            token:token,
            ym:ym,
            page:page,
            limit:100,
        };
        utils.request(data).then(function(res){
            if (res.code == 0) {
                var data = res.data.list
                var total = parseFloat(0);
                data.forEach((item, index) => {
                    data[index]['pic'] = c.img_url+item.pic;
                    total += parseFloat(item.order_total_money);
                });
                that.setData({
                    lists:data,
                    ym:res.data.ym,
                    total_money:total.toFixed(2)
                });
                wx.stopPullDownRefresh();
            }
        });
    },

    bindDateChange: function (e) {
        this.setData({
            ym: e.detail.value
        })
        this.getList();
    }
})